---
id: 65578d0f6c78a0b868a43b9c
title: Step 35
challengeType: 20
dashedName: step-35
---

# --description--

Inside the `while` loop, the first thing to do is define the current node to visit. For that you can use the `min()` function. It returns the smallest item from the iterable passed as the argument.

Remove `pass`, then create a variable called `current` and assign it `min(unvisited)`.

# --hints--

You should create a `current` variable in your `while` loop.

```js
({ test: () =>  {
    const shortest = __helpers.python.getDef(code, "shortest_path");
    const {function_body} = shortest;    
    assert(function_body.match(/^(\s{4})while\s+unvisited\s*:\s*^\1\1current\s*=/ms));
  }
})
```

You should assign `min(unvisited)` to your `current` variable.

```js
({ test: () =>  {
    const shortest = __helpers.python.getDef(code, "shortest_path");
    const {function_body} = shortest;    
    assert(function_body.match(/^(\s{4})while\s+unvisited\s*:\s*^\1\1current\s*=\s*min\s*\(\s*unvisited\s*\)/ms));
  }
})
```

# --seed--

## --seed-contents--

```py
my_graph = {
    'A': [('B', 3), ('D', 1)],
    'B': [('A', 3), ('C', 4)],
    'C': [('B', 4), ('D', 7)],
    'D': [('A', 1), ('C', 7)]
}

def shortest_path(graph, start):
    unvisited = list(graph)
    distances = {node: 0 if node == start else float('inf') for node in graph}
    paths = {node: [] for node in graph}
    paths[start].append(start)
--fcc-editable-region--
    while unvisited:
        pass
--fcc-editable-region--    
    print(f'Unvisited: {unvisited}\nDistances: {distances}\nPaths: {paths}')
    
#shortest_path(my_graph, 'A')

```
